package com.ycfmedical.bed.ui.fragment;

import java.io.File;

import com.ycfmedical.bed.R;

import android.os.Bundle;
import android.os.Environment;

import butterknife.BindView;
import cn.droidlover.xdroidmvp.imageloader.ILFactory;
import cn.droidlover.xdroidmvp.mvp.XLazyFragment;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard;

/**
 * Created by Egoist on 2017/1/19.
 */

public class VideoSingleFragment extends XLazyFragment
{
    
    @BindView(R.id.videoplayer)
    JCVideoPlayerStandard videoplayer;
    
    @Override
    public int getLayoutId()
    {
        return R.layout.fragment_entertain_video;
    }
    
    @Override
    public void initData(Bundle savedInstanceState)
    {
        File file = new File(Environment.getExternalStorageDirectory() + File.separator + "Movies" + File.separator + "transformer.mp4");
        String url = file.getAbsolutePath();
        videoplayer.widthRatio = 16;
        videoplayer.heightRatio = 10;
        videoplayer.setUp(url, JCVideoPlayer.SCREEN_LAYOUT_NORMAL,
                getString(R.string.video_item_trans));

        ILFactory.getLoader().loadResource(videoplayer.thumbImageView,R.raw.ic_thumb_transformer,null);
    }
    
    @Override
    public void onPauseLazy()
    {
        super.onPauseLazy();
        JCVideoPlayer.releaseAllVideos();
    }

    @Override
    protected void onStopLazy() {
        super.onStopLazy();
        JCVideoPlayer.releaseAllVideos();
    }

    @Override
    public Object newP()
    {
        return null;
    }
    
    public static VideoSingleFragment newInstance()
    {
        return new VideoSingleFragment();
    }
    
}
